package com.guang.springbootexception.controller;

import com.guang.springbootexception.exception.ServiceException;
import com.guang.springbootexception.exception.ServiceExceptions;
import org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author liguang
 * @date 2022/5/16 17:01
 */
@RestController
@RequestMapping(name = "ExceptionController",path = "exception")
public class ExceptionController {


    @RequestMapping(name = "helloException",value = "hello")
    public String helloException() throws ServiceException {
        boolean flag = true;
        if (flag){
            throw ServiceExceptions.F999.buildServiceException();
        }
        return "hello,exception";
    }

    @RequestMapping(name = "helloSuccess",value = "success")
    public String helloSuccess(@RequestParam(value = "name")String name,
                               @RequestParam(value = "age")Integer age){
        return "hello,helloSuccess";
    }


}
